/**
 * 镇长日志 - 清新浅色主题
 * 友好的白色背景 + 绿色自然主题
 */

/* ==================== CSS 变量 - 浅色主题 ==================== */
:root {
  /* 主题色 - 自然绿色 */
  --color-primary: #2D6A4F;      /* 深绿色 - 主色调 */
  --color-primary-light: #52B788; /* 浅绿色 */
  --color-secondary: #40916C;    /* 中绿色 */
  --color-accent: #FFB703;       /* 琥珀色 - 强调 */
  --color-danger: #E63946;
  --color-success: #52B788;
  --color-warning: #FB8500;

  /* 背景色 - 浅色舒适 */
  --color-bg: #F8FAF9;           /* 极浅的绿色背景 */
  --color-surface: #FFFFFF;      /* 纯白卡片 */
  --color-surface-hover: #F1F8F5; /* 悬停时的浅绿 */

  /* 文字色 */
  --color-text-primary: #1B4332;   /* 深绿色文字 */
  --color-text-secondary: #2D6A4F; /* 中绿色文字 */
  --color-text-tertiary: #74AA96;  /* 浅绿色文字 */

  /* 边框色 */
  --color-border: #D8F3DC;        /* 浅绿色边框 */
  --color-border-hover: #B7E4C7;  /* 悬停边框 */

  /* 资源颜色 */
  --color-wood: #8B4513;         /* 棕色 - 木材 */
  --color-food: #52B788;         /* 绿色 - 食物 */
  --color-population: #6366F1;   /* 蓝色 - 人口 */

  /* 阴影 - 柔和 */
  --shadow-sm: 0 1px 3px 0 rgba(45, 106, 79, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(45, 106, 79, 0.1), 0 2px 4px -1px rgba(45, 106, 79, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(45, 106, 79, 0.12), 0 4px 6px -2px rgba(45, 106, 79, 0.08);

  --nav-height: 60px;
  --tabs-height: 70px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* ==================== 全局布局 ==================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(135deg, #F8FAF9 0%, #E8F5E9 100%);
  color: var(--color-text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
}

body {
  display: flex;
  flex-direction: column;
}

/* ==================== 顶部导航栏 ==================== */
#game-navbar {
  height: var(--nav-height);
  background: linear-gradient(135deg, #2D6A4F 0%, #40916C 100%);
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
  z-index: 100;
}

.nav-content {
  height: 100%;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1400px;
  margin: 0 auto;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-left i {
  font-size: 1.5rem;
  color: #FFB703;
}

.nav-left h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
}

.nav-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  text-decoration: none;
  transition: all 0.2s;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

/* ==================== 主内容区域 ==================== */
#game-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  padding: 0;
}

.loading-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.loading-spinner {
  width: 3rem;
  height: 3rem;
  border: 4px solid rgba(45, 106, 79, 0.2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==================== 标签页内容 ==================== */
.tab-content {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  padding: 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-content.active {
  display: block;
}

.tab-content::-webkit-scrollbar {
  width: 6px;
}

.tab-content::-webkit-scrollbar-track {
  background: rgba(45, 106, 79, 0.05);
}

.tab-content::-webkit-scrollbar-thumb {
  background: rgba(45, 106, 79, 0.3);
  border-radius: 3px;
}

.tab-content::-webkit-scrollbar-thumb:hover {
  background: rgba(45, 106, 79, 0.5);
}

/* ==================== 底部标签栏 ==================== */
.main-tabs-nav {
  height: calc(var(--tabs-height) + var(--safe-area-bottom));
  padding-bottom: var(--safe-area-bottom);
  background: white;
  box-shadow: 0 -2px 10px rgba(45, 106, 79, 0.1);
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  flex-shrink: 0;
  z-index: 100;
}

.main-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  height: var(--tabs-height);
  background: transparent;
  border: none;
  color: var(--color-text-tertiary);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  padding: 0.5rem;
}

.main-tab i {
  font-size: 1.5rem;
  transition: all 0.2s;
}

.main-tab span {
  font-size: 0.75rem;
  font-weight: 500;
}

.main-tab.active {
  color: var(--color-primary);
}

.main-tab.active i {
  transform: translateY(-2px);
}

.main-tab.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  border-radius: 0 0 3px 3px;
}

.main-tab:active {
  transform: scale(0.95);
}

/* ==================== 总览标签页 ==================== */
.overview-grid {
  display: grid;
  gap: 1rem;
  height: 100%;
  grid-template-rows: auto 1fr auto;
}

/* 资源卡片 */
.resources-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.resource-card-mini {
  background: white;
  border: 2px solid var(--color-border);
  border-radius: 1rem;
  padding: 1rem;
  text-align: center;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.resource-card-mini:active {
  transform: scale(0.95);
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-md);
}

.resource-icon-mini {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: white;
  box-shadow: var(--shadow-md);
}

.resource-label {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.resource-amount {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 0.25rem;
}

.resource-production {
  font-size: 0.7rem;
  padding: 0.125rem 0.5rem;
  border-radius: 1rem;
  display: inline-block;
  font-weight: 600;
}

.resource-production.positive {
  background: #D8F3DC;
  color: #1B4332;
}

.resource-production.negative {
  background: #FFE5E5;
  color: #C41E3A;
}

/* 状态信息卡片 */
.info-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.info-card-small {
  background: white;
  border: 2px solid var(--color-border);
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.info-card-small:active {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-md);
}

.info-card-label {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.info-card-label i {
  color: var(--color-primary);
}

.info-card-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

/* 快捷操作 */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

/* ==================== 建筑/事件列表 ==================== */
.content-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.building-card-compact,
.event-card-compact {
  background: white;
  border: 2px solid var(--color-border);
  border-radius: 1rem;
  padding: 1rem;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.building-card-compact:active,
.event-card-compact:active {
  transform: scale(0.98);
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: white;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  box-shadow: var(--shadow-md);
}

.card-info {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.level-badge {
  padding: 0.125rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.7rem;
  background: linear-gradient(135deg, #6366F1, #4F46E5);
  color: white;
  font-weight: 600;
}

.card-desc {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

/* ==================== 按钮 ==================== */
.btn {
  width: 100%;
  padding: 0.875rem 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: white;
}

.btn-primary:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: linear-gradient(135deg, #6366F1, #4F46E5);
  color: white;
}

.btn-secondary:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-md);
}

.btn:disabled {
  background: #E8E8E8;
  color: #999999;
  cursor: not-allowed;
  box-shadow: none;
}

/* ==================== 日志 ==================== */
.logs-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 100%;
  overflow-y: auto;
}

.log-entry {
  background: white;
  border-left: 3px solid var(--color-primary);
  border-radius: 0.5rem;
  padding: 0.75rem;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.log-entry:active {
  box-shadow: var(--shadow-md);
}

.log-time {
  font-size: 0.7rem;
  color: var(--color-text-tertiary);
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.log-message {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

/* ==================== 空状态 ==================== */
.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--color-text-tertiary);
}

.empty-state i {
  font-size: 4rem;
  opacity: 0.3;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ==================== 通知 ==================== */
.notification {
  position: fixed;
  bottom: calc(var(--tabs-height) + var(--safe-area-bottom) + 1rem);
  left: 1rem;
  right: 1rem;
  max-width: 400px;
  margin: 0 auto;
  background: white;
  border: 2px solid var(--color-border);
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  transform: translateY(200%);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 1000;
}

.notification.show {
  transform: translateY(0);
  opacity: 1;
}

.notification i {
  font-size: 1.5rem;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.notification-content {
  flex: 1;
  min-width: 0;
}

.notification-title {
  font-weight: 700;
  display: block;
  margin-bottom: 0.25rem;
  color: var(--color-text-primary);
}

.notification-message {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

/* ==================== 进度条 ==================== */
.progress-bar {
  height: 6px;
  background: #E8F5E9;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  border-radius: 3px;
  transition: width 0.3s;
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ==================== 成本显示 ==================== */
.cost-display {
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: #F8FAF9;
  border-radius: 0.5rem;
  margin: 0.5rem 0;
  font-size: 0.85rem;
  border: 1px solid var(--color-border);
}

.cost-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--color-text-secondary);
  font-weight: 600;
}

.cost-icon-small {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: white;
  box-shadow: var(--shadow-sm);
}

/* ==================== 响应式 ==================== */
@media (min-width: 768px) {
  .resources-row {
    grid-template-columns: repeat(3, 1fr);
  }

  .info-cards-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .quick-actions {
    grid-template-columns: repeat(3, 1fr);
  }
}
